package com.hk.admin.common.dto.system.role;

import com.hk.admin.common.model.system.RoleModel;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class RoleDTO {

    private Long id;                 // id主键
    private String roleName;        // 角色名称
    private Integer roleStatus;     // 角色状态, 0:启用 ，1:禁用
    private String description;     // 角色描述
    private Date createTime;        //  创建时间

    private List<Long> menuIds = new ArrayList<>();     // 角色关联菜单的id

    public RoleDTO() {
    }

    public RoleDTO(RoleModel model) {
        this.id = model.getId();
        this.roleName = model.getRoleName();
        this.roleStatus = model.getRoleStatus();
        this.description = model.getDescription();
        this.createTime = model.getCreateTime();
    }

    public void fitMenuIds(RoleModel model) {
        model.getMenus().forEach(e -> this.menuIds.add(e.getId()));
    }

}
